import { createRouter, createWebHashHistory } from 'vue-router'
// 懒加载
const LayOut = () => import('@/views/Layout/index.vue')
const Home = () => import('@/views/Home/index.vue')
const Goods = () => import('@/views/Goods/index.vue')
const Login = () => import('@/views/Login/index.vue')
const Cart = () => import('@/views/Cart/index.vue')
const routes = [
  {
    path: '/',
    component: LayOut,
    children: [
      {
        path: '/',
        component: Home
      },
      {
        path: '/goods/:id',
        component: Goods
      },
      {
        path: '/cart',
        component: Cart
      }
    ]
  },
  // 登录一级路由
  {
    path: '/login',
    component: Login
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes,
  scrollBehavior () {
    return { top: 0 }
  }
})

export default router
